package com.sxm.yiwei.activitis;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.sxm.yiwei.MainActivity;
import com.sxm.yiwei.R;

public class RangingActivity extends BaseActivity implements View.OnClickListener{

    private ImageView rangingback;
    private EditText inaddress;
    private Button surebt;
    private String id,consignorLat,consignorLong;
    private String type;
    private ImageView backmain;

    /**
     *
     * 测距
     * @param savedInstanceState
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ranging);
        Intent intent = getIntent();
        id = intent.getStringExtra("id");
        consignorLat = intent.getStringExtra("consignorLat");
        consignorLong = intent.getStringExtra("consignorLong");

        initRangVew();
    }

    private void initRangVew() {
        rangingback = (ImageView) findViewById(R.id.ranging_back);
        inaddress = (EditText) findViewById(R.id.rang_inaddress);
        surebt = (Button) findViewById(R.id.rang_surebt);
        backmain = (ImageView) findViewById(R.id.ranging_backmain);
        backmain.setOnClickListener(this);
        rangingback.setOnClickListener(this);
        surebt.setOnClickListener(this);
        inaddress.setOnClickListener(this);
        inaddress.setKeyListener(null);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ranging_backmain:
                startActivity(new Intent(RangingActivity.this, MainActivity.class));
                AppManager.getAppManager().finishAllActivity();
                break;
            case R.id.rang_surebt:

                Intent rangintent = new Intent(RangingActivity.this,RangingInMessageActivity.class);
                rangintent.putExtra("consignorLat",consignorLat);
                rangintent.putExtra("consignorLong",consignorLong);
                rangintent.putExtra("id",id);
                startActivity(rangintent);
                break;
            case R.id.rang_inaddress:

                Intent addressIntent = new Intent(RangingActivity.this,RangingInMessageActivity.class);
                addressIntent.putExtra("consignorLat",consignorLat);
                addressIntent.putExtra("consignorLong",consignorLong);
                addressIntent.putExtra("id",id);
                startActivity(addressIntent);
                break;
            case R.id.ranging_back:
                finish();
                break;
        }
    }
}
